//
//  ZXStatusRetweetedFrm.m
//  ZXOCWeiBo
//
//  Created by mac on 15/12/10.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZXStatusRetweetedFrm.h"
#import "ZXStatusPhotosVIew.h"

@implementation ZXStatusRetweetedFrm

-(void)setRetweetedStatus:(ZXStatuses *)retweetedStatus
{
    _retweetedStatus = retweetedStatus;
    
    //计算内容的frm
    NSString * content = [NSString stringWithFormat:@"@%@: %@",retweetedStatus.user.screen_name,retweetedStatus.text];
//    赋值转发微博的内容
    retweetedStatus.retweeteContent = content;
    CGFloat contextX = ZXStatusCellInset;
    CGFloat contextY = 0;
    
    NSDictionary * textAtt = @{NSFontAttributeName : ZXStatusOrginlTextFont};
    CGSize maxSize = CGSizeMake(UIScreenW - ZXStatusCellInset * 2, MAXFLOAT);
    CGSize contextSize = [content boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:textAtt context:nil].size;
    self.contentFrm = (CGRect){contextX,contextY,contextSize};
    
    //配图的frm
    CGFloat photosX = contextX;
    CGFloat phptpsY = CGRectGetMaxY(self.contentFrm) + ZXStatusCellInset;
    CGSize photosSize = [ZXStatusPhotosVIew photosSizeWithPicCount:retweetedStatus.pic_urls.count];
    self.photosFrm = (CGRect){photosX,phptpsY,photosSize};
//ZXLog(@"=======%@",self.retweetedStatus.thumbnail_pic);
    
    
//    计算自身的frm
#warning 在外面一层从设置Y
    CGFloat selfH = CGRectGetMaxY(self.contentFrm) + ZXStatusCellInset;
    if (retweetedStatus.pic_urls.count > 0)
    {
        selfH = CGRectGetMaxY(self.photosFrm) + ZXStatusCellInset;
    }
    self.selfFrm = CGRectMake(0, 0, UIScreenW, selfH);
    
}


@end
